#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
python 学习
"""

__author__ = 'hubert'

import redis

# 采用链接池
def initconn():
    x = ''
    pool = redis.ConnectionPool(host='127.0.0.1', port=6379)
    try:
        r = redis.Redis(connection_pool=pool)
        r.set('cache', 'redis3.0')
    except:
        print('except:', "链接失败")
    return r.get('cache')

if __name__ == '__main__':
    value = initconn()
    print(value.decode('utf-8'))